//
//  RightMenuViewController.m
//  AloTruyen
//
//  Created by minhthong on 9/11/14.
//  Copyright (c) 2014 Khoai Nguyen Minh. All rights reserved.
//

#import "RightMenuViewController.h"
#import "RightMenuCell.h"

@interface RightMenuViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong) NSMutableArray *arrSettings;
@property (nonatomic,weak) IBOutlet UITableView *tableView;
@end

@implementation RightMenuViewController
#pragma mark - Initalize
-(NSMutableArray *)arrSettings{
    if (!_arrSettings) {
        _arrSettings = [NSMutableArray array];
    }
    return _arrSettings;
}
#pragma mark - Customize Subview
-(void)customizeSubView{
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.rowHeight = 45;
}
-(void)customizeBar{
    @autoreleasepool {
        /* setup title view */

        self.titleLabelString = @"THIẾT LẬP HỆ THỐNG";
        
    }
}

#pragma mark - Button Action
-(void)didTouchedOnLeftMenu:(id)sender{
    [appDelegate.revealController showViewController:appDelegate.
     revealController.frontViewController];
}
#pragma mark - Helper Method
-(void)addSetings{
    self.arrSettings = [NSMutableArray arrayWithObjects:
                        @{[[self class] description]:@"Tải sách",@"icon":@"icon_wifi"},
                        @{[[self class] description]:@"Trợ giúp",@"icon":@"icon_help"},
                        @{[[self class] description]:@"Thông tin về chúng tôi",@"icon":@"icon_about"}
                        , nil];
    [self.tableView reloadData];
}
#pragma mark - Init life vehicle
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self customizeBar];
    [self customizeSubView];
    [self addSetings];
    
    
    // Do any additional setup after loading the view.
}
-(void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    
    if (SupportiOS7) {
        if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
            self.edgesForExtendedLayout = UIRectEdgeNone;
        
        CGRect viewBounds = self.view.bounds;
        CGFloat topBarOffset = self.topLayoutGuide.length;
        viewBounds.origin.y = topBarOffset * -1;
        
        self.view.bounds = viewBounds;
        self.navigationController.navigationBar.translucent = NO;
    }
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - UITableViewDelegate
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.arrSettings.count;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *cellIdentifier = @"RightCell";
    RightMenuCell *cell = (RightMenuCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[IBHelper sharedUIHelper]loadViewNib:[[RightMenuCell class] description]];
    }
    NSDictionary *setting = self.arrSettings[indexPath.row];
    cell.title.text = setting[[[self class]description]];
    cell.title.font = FontOpenSanWithSize(14);
    cell.imageView.image = ImgWithName(setting[@"icon"]);
    if (indexPath.row != 0) {
        cell.onOff.hidden = YES;
        cell.checkMark.image = ImgWithName(@"icon_arrow");
    }else{
        
    }
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

@end
